﻿<div class="panel panel-default">
    <div class="panel-heading">
        <h2 ng-if="!vm.isEditMode">{{::vm.translate.get('Create SpaceBar Widget')}}</h2>
        <h2 ng-if="vm.isEditMode">{{::vm.translate.get('Edit SpaceBar Widget')}}</h2>
    </div>
    <div class="panel-body">
        <form name="pageForm" class="form-horizontal">
            <div class="col-sm-offset-2 bg-danger" ng-show="vm.validationErrors">
                <ul>
                    <li ng-repeat="error in vm.validationErrors">{{error}}</li>
                </ul>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">{{::vm.translate.get('Widget Name')}}</label>
                <div class="col-sm-10">
                    <input name="name" ng-model="vm.widgetInstance.name" class="form-control" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">{{::vm.translate.get('Widget Zone')}}</label>
                <div class="col-sm-10">
                    <select ng-model="vm.widgetInstance.widgetZoneId" class="form-control"
                            ng-options="zone.id as zone.name for zone in vm.widgetZones"></select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">{{::vm.translate.get('Publish Start')}}</label>
                <div class="col-sm-10">
                    <p class="input-group">
                        <input type="text" class="form-control" datetime-picker="dd MMM yyyy HH:mm" ng-model="vm.widgetInstance.publishStart" is-open="vm.datePickerPublishStart.open" datepicker-options="vm.datePickerPublishStart.datepickerOptions" />
                        <span class="input-group-btn">
                            <button type="button" class="btn btn-default" ng-click="vm.openCalendar($event, 'datePickerPublishStart')"><i class="fa fa-calendar"></i></button>
                        </span>
                    </p>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">{{::vm.translate.get('Publish End')}}</label>
                <div class="col-sm-10">
                    <p class="input-group">
                        <input type="text" class="form-control" datetime-picker="dd MMM yyyy HH:mm" ng-model="vm.widgetInstance.publishEnd" is-open="vm.datePickerPublishEnd.open" datepicker-options="vm.datePickerPublishEnd.datepickerOptions" />
                        <span class="input-group-btn">
                            <button type="button" class="btn btn-default" ng-click="vm.openCalendar($event, 'datePickerPublishEnd')"><i class="fa fa-calendar"></i></button>
                        </span>
                    </p>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">{{::vm.translate.get('Display Order')}}</label>
                <div class="col-sm-10">
                    <select ng-model="vm.widgetInstance.displayOrder" class="form-control"
                            ng-options="n for n in vm.numberOfWidgets"></select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">{{::vm.translate.get('Items')}}</label>
                <div class="col-sm-10">
                    <div class="form-group row tabbable-panel-line" ng-repeat="item in vm.widgetInstance.items">
                        <div class="col-md-11">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">{{::vm.translate.get('Image')}}</label>
                                <div class="col-sm-10">
                                    <input class="form-control" type="file" ngf-select ng-model="item.uploadImage" name="images" ngf-accept="'image/*'">
                                    <img ngf-src="item.uploadImage" ngf-resize="{width: 100, height: 100, quality: 0.9}">
                                    <img ng-show="!item.uploadImage && item.imageUrl" ng-src="{{item.imageUrl}}" style="width: 320px; height: 100px" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">{{::vm.translate.get('Icon:')}}</label>
                                <div class="col-sm-10">
                                    <input ng-model="item.iconHtml" class="form-control" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">{{::vm.translate.get('Title:')}}</label>
                                <div class="col-sm-10">
                                    <input ng-model="item.title" class="form-control" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">{{::vm.translate.get('Description:')}}</label>
                                <div class="col-sm-10">
                                    <input ng-model="item.description" class="form-control" />
                                </div>
                            </div>
                        </div>
                        <div class="col-md-1 text-right">
                            <button ng-click="vm.removeItem(item)" type="button" class="btn btn-default btn-xs">
                                <span class="glyphicon glyphicon-remove"></span>
                            </button>
                        </div>
                    </div>
                    <button ng-click="vm.addItem()" type="button" class="btn btn-default">
                        <span class="glyphicon glyphicon-plus"></span> {{::vm.translate.get('Add more')}}
                    </button>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <button class="btn btn-primary" ng-click="vm.save()"><span class="glyphicon glyphicon-ok"></span> {{::vm.translate.get('Save')}}</button>
                    <button ui-sref="widget" class="btn btn-default">{{::vm.translate.get('Cancel')}}</button>
                </div>
            </div>
        </form>
    </div>
</div>